﻿using LNet;
using OestsCommon.Model;
using OestsServer.Net;

namespace OestsServer.Handlers.UnityHandlers
{
    /*
     * 同一个项目种 转发数据
     */
    public class TransmitHandler : HandlerBase<UnityClientChannel>
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        public override PacketKey PKey
        {
            get
            {
                return PacketKey.Transmit;
            }
        }


        public override void Execute(UnityClientChannel client, Request packet)
        {
            TransmitObject to = LitJson.JsonMapper.ToObject<TransmitObject>(packet.DataStr);
            ResponsePacket = new Response(packet);

            foreach (var rec in to.ReceiveUsers)
            {
                UnityClientChannel.Signal_ID.Dispatch(rec, ResponsePacket);
            }
        }
    }
}
